{% extends "./layout.html" %}

{% block title %}{{ "LANGS_CHOOSE"|t }} · {{ super() }}{% endblock %}

{% block head %}
{{ super() }}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
{% endblock %}

{% block body %}
<div class="language-selector-container">
    <!-- hero section -->
    <div class="hero-section">
        <div class="hero-content">
            <h1>Learn JavaScript</h1>
            <p class="subtitle">Beginner's Edition</p>
            <div class="version-badge">First Edition</div>
            
            <div class="hero-meta">
                <span><i class="fas fa-globe"></i> Web Version</span>
                <span><i class="fas fa-calendar-alt"></i> Updated: 2025-05-21</span>
            </div>
        </div>
        
        <div class="book-cover-container">
            <img src="./cover.jpg" alt="Learn JavaScript Book Cover" class="book-cover">
            <div class="cover-shine"></div>
        </div>
    </div>

    <!-- language selection -->
    <div class="language-selection-section">
        <div class="section-header">
            <h2><i class="fas fa-language"></i> {{ "LANGS_CHOOSE"|t }}</h2>
            <p>Select your preferred language to begin your JavaScript journey</p>
        </div>
        
        <div class="language-grid">
            {% for lang in languages.list %}
            <div class="language-card">
                <div class="card-content">
                    <div class="language-icon">
                        <i class="fas fa-code"></i>
                    </div>
                    <h3>{{ lang.title }}</h3>
                </div>
                <div class="card-actions">
                    {% if lang.id == 'de' %}
                        <a href="{{ (lang.id + "/README.md")|contentURL }}" class="action-btn preview">
                            <i class="fas fa-eye"></i> Preview
                        </a>
                    {% else %}
                        <a href="{{ (lang.id + "/README.md")|contentURL }}" class="action-btn preview">
                            <i class="fas fa-eye"></i> Preview
                        </a>
                        <a href="https://github.com/sumn2u/learn-javascript/raw/main/books/book_{{ lang.id }}.pdf" class="action-btn download">
                            <i class="fas fa-download"></i> PDF
                        </a>
                    {% endif %}
                </div>
            </div>
            {% endfor %}
        </div>
    </div>

    <!-- footer -->
    <div class="footer-section">
        <div class="author-info">
            <div class="author-avatar">
                <i class="fas fa-user-tie"></i>
            </div>
            <div class="author-details">
                <h4>Suman Kunwar</h4>
                <div class="publication-info">
                    <span>ASIN: B0C53J11V7</span>
                    <span>ISBN: 9789937171892</span>
                </div>
            </div>
        </div>
        
        <div class="license-info">
            <p>
                <i class="fas fa-balance-scale"></i> Licensed under 
                <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache 2.0</a>
            </p>
            <p>
                <i class="fab fa-github"></i> Source at 
                <a href="https://github.com/sumn2u/learn-javascript" target="_blank">GitHub</a>
            </p>
        </div>
    </div>
</div>

<style>

:root {
    --primary-color: #4361ee;
    --secondary-color: #3a0ca3;
    --accent-color: #f72585;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --text-color: #495057;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    background-color: #f5f7ff;
    margin: 0;
    padding: 0;
}

.language-selector-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* hero styles */
.hero-section {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4rem;
    padding: 3rem 0;
    position: relative;
}

.hero-content {
    flex: 1;
    min-width: 300px;
    padding-right: 3rem;
    z-index: 2;
}

.hero-content h1 {
    font-size: 3.5rem;
    margin: 0;
    color: var(--dark-color);
    font-weight: 800;
    line-height: 1.2;
    background: linear-gradient(90deg, #4361ee, #3a0ca3);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    font-size: 1.5rem;
    color: var(--text-color);
    margin: 0.5rem 0 1.5rem;
    font-weight: 400;
}

.version-badge {
    display: inline-block;
    background: var(--accent-color);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(247, 37, 133, 0.3);
}

.hero-meta {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}

.hero-meta span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-color);
}

.book-cover-container {
    position: relative;
    width: 300px;
    height: 400px;
    perspective: 1000px;
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    transform: rotateY(-10deg);
    transition: transform 0.5s ease;
    position: relative;
    z-index: 1;
}

.cover-shine {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 60%);
    border-radius: 8px;
    z-index: 2;
}

/* language selection styles */
.language-selection-section {
    margin: 5rem 0;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-header h2 {
    font-size: 2.2rem;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.section-header p {
    color: var(--text-color);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

.language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.language-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.language-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.card-content {
    padding: 2rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.language-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #4361ee, #3a0ca3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: white;
    font-size: 1.5rem;
}

.language-card h3 {
    margin: 0;
    color: var(--dark-color);
    font-size: 1.3rem;
    font-weight: 600;
}

.card-actions {
    display: flex;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.action-btn {
    flex: 1;
    text-align: center;
    padding: 1rem;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.preview {
    background: var(--light-color);
    color: var(--primary-color);
}

.preview:hover {
    background: #e9ecef;
}

.download {
    background: var(--primary-color);
    color: white;
}

.download:hover {
    background: var(--secondary-color);
}

/* footer selection styles */
.footer-section {
    margin-top: 6rem;
    padding-top: 3rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2rem;
}

.author-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.author-avatar {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #4361ee, #3a0ca3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.8rem;
}

.author-details h4 {
    margin: 0 0 0.5rem;
    font-size: 1.3rem;
    color: var(--dark-color);
}

.publication-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-color);
}

.license-info {
    max-width: 400px;
}

.license-info p {
    margin: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.license-info a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.license-info a:hover {
    text-decoration: underline;
}

/* responsive */
@media (max-width: 768px) {
    .hero-section {
        flex-direction: column;
        text-align: center;
        padding: 2rem 0;
    }
    
    .hero-content {
        padding-right: 0;
        margin-bottom: 3rem;
    }
    
    .hero-meta {
        justify-content: center;
    }
    
    .book-cover-container {
        margin: 0 auto;
    }
    
    .footer-section {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .author-info {
        flex-direction: column;
        text-align: center;
    }
}

/* animate */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.language-card {
    animation: fadeIn 0.6s ease forwards;
    opacity: 0;
}

.language-card:nth-child(1) { animation-delay: 0.1s; }
.language-card:nth-child(2) { animation-delay: 0.2s; }
.language-card:nth-child(3) { animation-delay: 0.3s; }
.language-card:nth-child(4) { animation-delay: 0.4s; }
.language-card:nth-child(5) { animation-delay: 0.5s; }
.language-card:nth-child(6) { animation-delay: 0.6s; }
</style>
{% endblock %}